<script setup>
import { ref } from 'vue'
import { useStore } from '@/store'

const userStore = useStore()
const userInfo = ref({})

// 获取用户信息
const getUserInfo = async () => {
  if (userStore.token) {
    userInfo.value = await userStore.getUserInfo()
  }
}

getUserInfo()
</script>

<template>
  <div class="profile-container">
    <el-card class="profile-card">
      <template #header>
        <div class="card-header">
          <span>个人中心</span>
        </div>
      </template>
      
      <div class="user-info">
        <el-avatar :size="80" :src="userInfo.avatar || 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'" />
        <h2>{{ userInfo.username || '未登录' }}</h2>
      </div>
      
      <el-descriptions title="个人信息" :column="1" border>
        <el-descriptions-item label="用户名">{{ userInfo.username || '暂无' }}</el-descriptions-item>
        <el-descriptions-item label="邮箱">{{ userInfo.email || '暂无' }}</el-descriptions-item>
        <el-descriptions-item label="手机号">{{ userInfo.phone || '暂无' }}</el-descriptions-item>
      </el-descriptions>
    </el-card>
  </div>
</template>

<style scoped>
.profile-container {
  padding: 20px;
}

.profile-card {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.card-header {
  font-size: 18px;
  font-weight: bold;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 20px 0 30px;
}

.user-info h2 {
  margin-top: 10px;
  font-size: 22px;
}
</style> 